class String
  def basename
   return File.basename(self)
  end
end
DEF_EXT = ["briefs","NavTools"]
module MuIDE
class InterClientSetup
attr_accessor :list,:client,:object,:briefsObject
  def initialize(*args)
	super *args
	$client = self
# p @m_notebook1
# 	@m_textctrl101.evt_key_up {|e| handle_key(e,@m_textctrl101)}
	@m_textctrl111.evt_key_up {|e| handle_key(e,@m_textctrl111)}
	@m_textctrl12.evt_key_up {|e| handle_key(e,@m_textctrl12)}
#         evt_button(@m_button12.get_id) {|e| getLogInString() }
	# @m_textctrl11.evt_key_up {|e| handle_key(e,@m_textctrl11)}
	@m_textctrl13.background_colour = Wx::Colour::new("BLACK")
        extend()
        @history = {@m_textctrl101=>History::new,
                    @m_textctrl111=>History::new,
                    @m_textctrl12=>History::new
                   }

221
111
12
101
  end
  def briefs(index=nil)
    if index == nil
      index = 0
    end
#     p @briefs
    @m_textctrl221.value = @briefsObject.get_brief(index)
  end
  def briefsTOC
    @m_textctrl221.value = @briefsObject.get_toc
  end



  def handle_key(e,widget)
    if ( e.get_modifiers == Wx::MOD_CONTROL )
      if widget.class == Wx::TextCtrl
        str = widget.value
        code = e.get_key_code
      else
        str = widget.get_text
        code = e.get_key_code
      end
     case code
       when 80
         if widget.class == Wx::TextCtrl
           widget.value = @history[widget].get_prev
         else
           widget.set_text(@history[widget].get_prev)
         end
       when 78
         if widget.class == Wx::TextCtrl
           widget.value = @history[widget].get_next
         else
           widget.set_text(@history[widget].get_next)
         end
       when 83
         @history[widget].enter(str)
         @client.socket.puts str
         if widget.class == Wx::TextCtrl
           widget.value = ""
         else
           widget.set_text("")
         end
       when 69
         begin
           @history[widget].enter(str)
           eval str
         rescue Exception => er
	  err = "Error: #{er.to_s}\n"
	  err += "Platform: #{Wx::PLATFORM}\n"
	  err += "MuIDE Version: #{VERSION}\n"
	  err += "Ruby Version: #{RUBY_VERSION}\n"
	  err += "Backtrace:\n\t"
	  err += er.backtrace.join("\n\t")
	  File.open("evalMuIDE.err","w") do |fh|
		fh.print(err)
	  end
	  #dir = File.dirname(File.expand_path(__FILE__))
	  if Wx::PLATFORM == "WXMSW"
		Kernel.exec("rubyw #{Dir.getwd}\\libs\\classes\\gui\\wxEvalError.rb")
	  else
		system("ruby libs/classes/gui/wxEvalError.rb")
	  end
        end
     else e.skip
     end
   end
  end
end
end